go to previous page   go to home page   go to next page

Answer:

ButtonFrame implements the ActionListener interface, so it must define each method described in the interface.


Implementing an Interface

For the ActionListener interface, there is only one method: actionPerformed(). Here is the program with a start on adding a listener:

class ButtonFrame2 extends JFrame implements 
{
  JButton bChange ;

  // constructor   
  public ButtonFrame2(String title) 
  {
    super( title );
    setLayout( new FlowLayout() );  

    bChange = new JButton("Click Me!"); 
    add( bChange ); 
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );    
  }
   
  // listener method required by the interface
  public void ( ActionEvent evt)
  {
     . . . . . .
  }
}

QUESTION 11:

Fill in the blanks. (Hint: copy and paste from the first sentence of this page.)